package org.example;

public class Test3 {
    //leetcode 长度最小的子数组
    public int minSubArrayLen(int target, int[] nums) {
        int n = nums.length;
        int left = 0, right = 0, sum = 0, ret = 100001;
        while (right < n) {
            while (right < n && sum < target) {
                sum += nums[right];
                right++;
            }
            while (left < right && sum >= target) {
                ret = Math.min(ret,right-left);
                sum -= nums[left];
                left++;
            }
        }
        return ret == 100001 ? 0 : ret;
    }

    public static void main(String[] args) {
        Test3 test3 = new Test3();
        int[] arr = {1,2,3,4,5};
        test3.minSubArrayLen(11,arr);
        System.out.println(666);
    }
}
